<?php 
define('PAGE_NEED_PRI','PRI_SALE');
session_start();
include("main.php");
include("../inc/JSON.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title> Bios 管理中心 </title>
<link href="../css/control.css" rel="stylesheet" type="text/css" />
</head>

<body>
<script language="javascript">


function ConfirmDel()
{
   if(confirm("確定要刪除選擇的項目嗎？一旦刪除將不能恢複！"))
     return true;
   else
     return false;	 
}


function check_fabu(a,b)
{
if(a>=b){
alert("請修改正確的發表時間！");
return false;
}
 
}

function check_end(a,b)
{
   if(confirm("警告：廣告正在上線中，是否讓廣告下線！"))
     return true;
   else
     return false;	 
}
 


</script>

<a name="top" id="top"></a>
<div id="all"><!--Wrap start //-->
<div id="main" class="clearfix"><!--main start //-->
<div id="top-1"><?php include_once('blog_top_btn.php');?>
</div>
<!--Content for  id "submenu" Goes Here //-->
<div id="submenu">
<?php include_once('ad_sale_main_btn.php');?>
  </div>
  
 <!--Content for  id "contact" Goes Here //-->
 <div id="contact">
 
 
 
 
 
  <?php
//文件名。。。
 $webname="ad"; 
?>
 
 <?php
$id=make_safe($_GET["id"]);
$images=make_safe($_GET["images"]);
$action=make_safe($_GET["action"]);
$item =make_safe($_POST["items"]);

include("check.php");


//删除数据
if ($id!="" and $action=="del") {
	

			
		$sql="select * from ".$webname."  where id in (".$id.")  ";			
	$result=mysql_query($sql);
	while ($row=mysql_fetch_object($result)){
     
	if($row->images){@unlink($row->images);}
	if($row->images2){@unlink($row->images2);}
	if($row->images3){@unlink($row->images3);}
	if($row->images4){@unlink($row->images4);}
	if($row->images5){@unlink($row->images5);}
	if($row->images6){@unlink($row->images6);}
	if($row->images7){@unlink($row->images7);}
	if($row->images8){@unlink($row->images8);}
	if($row->images9){@unlink($row->images9);}
	
	}	
	
	$sql="Delete from ".$webname."   where id in (".$id.")";
			$result=mysql_query($sql);	
			
	
	echo "<script>window.location.href='ad-sale-main.php?page=".$page."';</script>";

}
?>




  <?php 
 $action=make_safe($_GET["action"]);
 $begintime=$data2;
 if($action=="isok"){
$isok=make_safe($_GET["isok"]);

if($isok==0){
$query=mysql_query("update ".$webname." set isok='$isok',begintime='$begintime' where id='$id'");
}
if($isok==1){
$query=mysql_query("update ".$webname." set isok='$isok' where id='$id'");
}

	echo "<script>window.location.href='ad-sale-main.php?page=".$page."';</script>";
}
 
 
 ?>
 
 
 
 
 
 
 <?php 
		$webname="ad";
		 $BigClassName=make_safe($_GET["BigClassName"]);
		 $isok=make_safe($_GET["isok"]);
		 $timeok=make_safe($_GET["timeok"]);
		 $title2=make_safe($_GET["title"]);
		 
   if($page){
    $page_size=10;
	$sql="select count(*) as total from ".$webname." where id>0 ";
	//if($BigClassName!=""){$sql=$sql." and BigClassName='$BigClassName'";}
	if($isok!=""){$sql=$sql." and isok='$isok'";}
	if($timeok!="" ){$sql=$sql." and endtime<'$data3'";}
	//if($SmallClassName!=""){$sql=$sql." and SmallClassName='$SmallClassName'";}
	if($title2!=""){$sql=$sql." and title like '%".$title2."%'";}
	
	if($_SESSION["box55"]==1){$sql=$sql." and mastersalename='".$_SESSION["username2"]."'";}
	if($_SESSION["box66"]==1){$sql=$sql." and salename='".$_SESSION["username2"]."'";}
	if($_SESSION["box77"]==1){$sql=$sql." and design='".$_SESSION["username2"]."'";}
	
	
	
	$result=mysql_query($sql);
    $message_count=mysql_result($result,0,"total");
    $page_count=ceil($message_count/$page_size);	
    $offset=($page-1)*$page_size;	
	$sql="select * from ".$webname." where id>0 ";
	if($BigClassName!=""){ $sql=$sql."and BigClassName='$BigClassName'";}
	if($BigClassName!=""){$sql=$sql." and BigClassName='$BigClassName'";}
	if($timeok!="" ){$sql=$sql." and endtime>='$data3'";}
	if($isok!=""){$sql=$sql." and isok='$isok'";}
	if($title2!=""){$sql=$sql." and title like '%".$title2."%'";}
	
	
	
	
	
	$sql=$sql."order by id desc limit $offset, $page_size";
	$result=mysql_query($sql);
	while ($row=mysql_fetch_object($result)){
	
	
	?>
   <table border="0" cellspacing="0" cellpadding="0">
     <tr>
       <td><a href="../ad/ad.html" target="_blank">廣告主題：<?php echo $row->title;?></a></td>
     </tr>
     <tr>
       <td><ul>
         <li>撰寫時間：<?php echo $row->addtime;?></li>
         <li>發佈時間：<?php echo $row->begintime;?></li>
         <li>結束時間：<?php echo $row->endtime;?></li>
         <li>點閱次數：<?php echo $row->hits;?></li>
         </ul></td>
     </tr>
     <tr>
       <td><ul>
         <li>修改時間：<?php echo $row->edittime;?></li>
         <li>修改人：<?php echo $row->editname;?></li>
         </ul></td>
     </tr>
     <tr>
       <td><ul>
	   
	   <?php if($_SESSION["PRI_ADMIN"]==1  or $_SESSION["PRI_SALE"]==1   ){?>
          <li><a href="ad-sale-edit.php?id=<?php echo $row->id;?>">編輯</a></li>
		  <?php }?>
		  
          <?php if($_SESSION["PRI_ADMIN"]==1 or $_SESSION["PRI_SALE"]==1) {?>
          <li><?php if($row->isok=="0"){?><a  href="?isok=1&action=isok&id=<?php echo $row->id;?>" onClick="return check_end('<?php echo $row->starttime;?>','<?php echo $row->endtime;?>');">暫停發佈</a><?php }else{?><a style="color:#FF0000" href="?isok=0&action=isok&id=<?php echo $row->id;?>" onClick="return check_fabu('<?php echo $row->starttime;?>','<?php echo $row->endtime;?>');">恢復發佈</a><?php }?></li>
		<?php }?>  
		  
		  
		  <?php if($_SESSION["PRI_ADMIN"]==1  or $_SESSION["PRI_SALE"]==1    ){?>
		  <li><a href="?action=del&id=<?php echo $row->id;?>&page=<?php echo $page;?>" onClick="return ConfirmDel();">刪除</a></li>
		  <?php }?>
		  
		  
		  
       </ul></td>
     </tr>
     </table>
<?php }}?>





 </div>
  <!--Content for  id "contact_page" Goes Here //-->


<div id="contact_page">總共&nbsp;<?php echo $message_count;?> 條記錄&nbsp;&nbsp;頁次：
			  <?php 
			  $BigClassName=make_safe($_GET["BigClassName"]);
			  $BigClassName=urlencode($BigClassName);
			  if($page!=1)
				   {
				     echo  "<a href=?page=1&BigClassName=".$BigClassName.">首頁</a>&nbsp;&nbsp;&nbsp;";
					 echo "<a href=?page=".($page-1)."&BigClassName=".$BigClassName.">上一頁</a>&nbsp;&nbsp;&nbsp;";
				   } echo $page;?> / <?php echo $page_count;?> 頁&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
              <?php
	  		  
				  if($page<$page_count)
				   {
				        echo "<a href=?page=".($page+1)."&BigClassName=".$BigClassName.">下一頁</a>&nbsp;&nbsp;&nbsp;";
				        echo  "<a href=?page=".$page_count."&BigClassName=".$BigClassName.">尾頁</a>&nbsp;&nbsp;&nbsp;&nbsp;";
				   
				   }
				   
				 
				?>
                 &nbsp;&nbsp;&nbsp;跳轉到
                 <script type="text/javascript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
//-->
</script>
                 <select name="jumpMenu" id="jumpMenu" onChange="MM_jumpMenu('self',this,0)">
                 
                 <?php 
				 for($i=1;$i<=$page_count;$i++){
				 ?>
                   <option value="?page=<?php echo $i;?>" <?php if($page==$i){echo "selected";}?>><?php echo $i;?></option>
                   <?php }?>
                   </select>頁</div>



</div><!-- main end //-->
</div><!--Wrap end //-->
<div id="botton">
 <?php include_once('ad_sale_botton_btn.php');?>
</div>
</body>
</html>
